#include <QCoreApplication>
#include <QtSql>

int main(int argc, char *argv[])
{
	QCoreApplication app(argc, argv);

	QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE","wj");
    db.setDatabaseName("12345678.db");
	db.setUserName("admin");
	db.setPassword("admin");
	if(!db.open())
		qDebug()<<"open error";

	QSqlQuery query(db);
	query.exec("create table person(id int primary key, name varchar(30), sex varchar(8))");
	query.exec("insert into person values(101, 'weijie', 'man')");
	query.exec("insert into person values(103, 'wj', 'woman')");

	query.exec("select * from person");
	query.first();
	qDebug()<<query.value(0);
	qDebug()<<query.value(1);
	qDebug()<<query.value(2);
	query.next();
	qDebug()<<query.value(0);
	qDebug()<<query.value(1);
	qDebug()<<query.value(2);

	return 0;
}
